<template>
  <el-dialog
    style="border-radius: 20px"
    v-model="dialogVisible"
    :width="width"
    :before-close="handleClose"
  >
    <div class="favoritesadd">
      <span>{{
        favoritesType == 1
          ? "添加收藏夹"
          : favoritesType == 2
          ? "编辑未整理的收藏"
          : ""
      }}</span>
    </div>
    <div v-if="favoritesType == 2">
      <div class="name">
        <span>选择收藏夹</span>
        <div class="shoucan f-j-sb-a-c click" @click="shoucanClick">
          <span>{{ chooseitem }}</span>
          <svg-icon name="icon-zk"></svg-icon>
        </div>
      </div>
      <div class="list" v-if="shoucanCheck">
        <div
          class="listitem f-a-c"
          v-for="(item, index) in shoucanList"
          :key="index"
          @click="xuanze(item)"
        >
          <span>{{ item.title }}</span>
        </div>
      </div>
      <div class="buttonlist f-a-c">
        <div class="button click f-j-a-c">取消</div>
        <div class="buttons click f-j-a-c">确定</div>
      </div>
    </div>

    <div v-if="favoritesType == 1">
      <div class="name">
        <span>名称</span>
        <div class="input">
          <input type="text" v-model="name" placeholder="请输入名称" />
        </div>
      </div>
      <div class="name">
        <span>简介</span>
        <div class="textarea">
          <textarea
            name=""
            v-model="jianjie"
            id=""
            cols="30"
            rows="10"
            placeholder="这人很懒什么也没写~"
          ></textarea>
        </div>
      </div>
      <div class="name">
        <span>状态</span>
        <div class="mb-2 flex items-center text-sm">
          <el-radio-group v-model="radio1" class="ml-4">
            <el-radio label="1" size="large">对所有人可见</el-radio>
            <el-radio label="2" size="large">设为私密</el-radio>
          </el-radio-group>
        </div>
      </div>
      <div class="buttonlist f-a-c">
        <div class="button click f-j-a-c">取消</div>
        <div class="buttons click f-j-a-c">创建</div>
      </div>
    </div>
  </el-dialog>
</template>

<script>
import { useRouter } from "vue-router";
import {
  computed,
  defineComponent,
  onMounted,
  reactive,
  toRefs,
  getCurrentInstance,
  onUnmounted,
} from "vue";
import { useStore } from "vuex";
export default defineComponent({
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
    favoritesType: {
      type: Number,
      default: 0,
    },
    width: {
      type: Number,
      default: 0,
    },
    shoucanList: {
      type: Array,
      default: [],
    },
  },
  setup(props, { attrs, slots, emit }) {
    const router = useRouter();
    const { proxy } = getCurrentInstance();
    let store = useStore();
    let data = reactive({
      chooseitem: "收藏夹",
      jianjie: "",
      radio1: "",
      shoucanCheck: false,
    });
    onMounted(() => {});
    onUnmounted(() => {});
    let handleClose = () => {
      emit("close");
    };
    let shoucanClick = () => {
      data.shoucanCheck = !data.shoucanCheck;
    };
    let xuanze = (item) => {
      data.chooseitem = item.title;
      data.shoucanCheck = false;
    };
    return {
      xuanze,
      shoucanClick,
      handleClose,
      ...toRefs(data),
    };
  },
});
</script>
<style lang="scss" scoped>
.list {
  position: absolute;
  top: 178px;
  left: 18px;
  width: 357px;
  height: 180px;
  background: #ffffff;
  box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, 0.1);
  border-radius: 10px 10px 10px 10px;
  opacity: 1;
  background-color: #fff;
  .listitem {
    cursor: pointer;
    padding: 0 20px;

    height: 40px;
    > span {
      font-size: 14px;
      font-family: Microsoft YaHei-Regular, Microsoft YaHei;
      font-weight: 400;
      color: #000000;
    }
    &:hover {
      background: rgba(100, 200, 220, 0.12);
      > span {
        font-size: 14px;
        font-family: Microsoft YaHei-Regular, Microsoft YaHei;
        font-weight: 400;
        color: #64c8dc;
      }
    }
  }
}
.shoucan {
  padding: 0 20px;
  margin-top: 10px;
  height: 46px;
  border-radius: 10px 10px 10px 10px;
  opacity: 1;
  border: 1px solid #ececec;
}
.buttonlist {
  margin-top: 47px;
  justify-content: flex-end;
  .button {
    width: 80px;
    height: 40px;
    background: #f3f4f5;
    border-radius: 10px 10px 10px 10px;
    opacity: 1;
    font-size: 14px;
    font-family: Microsoft YaHei-Bold, Microsoft YaHei;
    font-weight: 700;
    color: #656f79;
  }
  .buttons {
    margin-left: 10px;
    width: 80px;
    height: 40px;

    background: linear-gradient(90deg, #9ed8e6 0%, #a1f0c0 100%);
    border-radius: 10px 10px 10px 10px;
    opacity: 1;
    font-size: 14px;
    font-family: Microsoft YaHei-Bold, Microsoft YaHei;
    font-weight: 700;
    color: #ffffff;
  }
}
.favoritesadd {
  position: absolute;
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 20px;
  > span {
    font-size: 16px;
    font-family: Microsoft YaHei-Bold, Microsoft YaHei;
    font-weight: 700;
    color: #000000;
  }
}
.name {
  margin-top: 40px;
  > span {
    font-size: 14px;
    font-family: Microsoft YaHei-Bold, Microsoft YaHei;
    font-weight: 700;
    color: #000000;
  }
  .input {
    width: 440px;
    height: 46px;
    opacity: 1;
    margin-top: 10px;
    > input {
      padding: 0 20px;
      width: 100%;
      height: 100%;
      border: none;
      border: 1px solid #ececec;
      border-radius: 10px 10px 10px 10px;
    }
  }
}
.textarea {
  margin-top: 10px;
  > textarea {
    padding: 11px 20px;
    border-radius: 10px 10px 10px 10px;
    border: 1px solid #ececec;
    width: 100%;
    height: 100px;
    overflow: auto;
  }
}
textarea:focus {
  outline: none;
}
/* 滚动条整体样式 */
textarea::-webkit-scrollbar {
  width: 3px;
  height: 3px;
}

/* 滚动条滑块样式 */
textarea::-webkit-scrollbar-thumb {
  background-color: #ececec;
  border-radius: 2px;
}

/* 滚动条轨道样式 */
textarea::-webkit-scrollbar-track {
  background-color: #f7f9fa;
}

/* 鼠标悬停时滚动条轨道样式 */
textarea::-webkit-scrollbar-track:hover {
  background-color: #f7f9fa;
}
textarea {
  resize: none;
}
</style>
